Parser assignment

  • Description
  • Grammar definition
  • Test programs
  • Description

    Write the parser, the second phase of your compiler.  The parser should use your previous scanner to read all tokens of an input program and check whether the program is grammatically correct.  The specific requirements are:

    Additional requirement

    Count the number of variables, functions (<func>), and statements (<statement>) in correct programs.  Output the result in the following format: variable _num_variables  function _num_functions statement _num_statements.  For example, for a correct program with 4 variables, 2 functions and 6 statements, your compiler should output at least the following:

        Pass variable 4 function 2 statement 6

    Test programs

    A list of 8 standard test programs can be downloaded from here.  Scroll down to see the content of README.